package com.rhythm.commons.math;

import java.util.Collection;

/**
 *
 * @author Michael J. Lee @ Synergy Energy Holdings, LLC
 */
public final class Calculator
{

    private Calculator() {
    }






    /**
     * Adds all the values in the give collection.  May throw a
     * NPE if one of the values is null.
     * @param values the values to add
     * @return the result
     * @throw NullPointerException if any values are null
     */
    public static int sum(Collection<Integer> values) {

        int sum = 0;

        for (Integer value : values)        
                sum += value;
        
        return sum;
    }

    /**
     * Adds all the values in the give collection.  May throw a
     * NPE if one of the values is null.
     * @param values the values to add
     * @return the result if any values are null
     */
    public static double sum(Collection<Double> values) {

        double sum = 0;

        for (Double value : values)        
                sum += value;
        
        return sum;
    }
}
